//
//  FCRadiusAlertView.m
//  webViewLocal
//
//  Created by WJC on 2021/5/12.
//

#import "FCRadiusAlertView.h"

@implementation FCRadiusAlertView
-(id)initWithTopRadiusFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame])
    {
    self.backgroundColor = [UIColor whiteColor];
    UIBezierPath *fieldPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, frame.size.width, frame.size.height) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(30 , 30)];

    CAShapeLayer *fieldLayer = [[CAShapeLayer alloc] init];

    fieldLayer.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);

    fieldLayer.path = fieldPath.CGPath;

    self.layer.mask = fieldLayer;
    }
    return self;
}
-(void)resetRadius{
    [self.layer.mask removeFromSuperlayer];
    UIBezierPath *fieldPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(30 , 30)];

    CAShapeLayer *fieldLayer = [[CAShapeLayer alloc] init];

    fieldLayer.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);

    fieldLayer.path = fieldPath.CGPath;

    self.layer.mask = fieldLayer;
}
-(id)initWithRadiusFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame])
    {
    self.backgroundColor = [UIColor whiteColor];
    self.layer.cornerRadius = 30;
    }
    return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
